<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="telephone=no" name="format-detection" />
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable = no"/>
    <title>注册-{$webseting.web_title}</title>
    <link href="__PUBLIC__/wap/css/rest.css"  rel="stylesheet">
    <link href="__PUBLIC__/wap/css/lrstyle.css"  rel="stylesheet">

    <!--address start-->
    <link href="__PUBLIC__/wap/css/user.css"  rel="stylesheet">
    <link href="__PUBLIC__/wap/css/mobiscroll.custom-2.5.0.min.css" rel="stylesheet" type="text/css"/>
    <!--address end-->

</head>
<body>
<header id="header" class="u-header clearfix">
    <div class="u-hd-left f-left">
        <a href="javascript:history.go(-1);" class="J_backToPrev"><span class="u-icon-px i-hd-back"></span></a>
    </div>
    <div class="u-hd-tit"><span>{$webseting.web_title}注册</span></div>
    <div class="rightBox">
        <a id="register_btn" href="{:U('Wap/Login/index')}" class="right rbtn">
            登陆
        </a>
    </div>
</header>
<form action="" role="form" id="form2" novalidate="novalidate" method="post" onSubmit="return false;">
    <div class="con_box show">
        <div class="step_1">
            <div class="form_box">
                <div class="form_item">
                    <!-- <label class="icon-cell_phone" for="code"></label> -->
                    <label><img src="__PUBLIC__/wap/img/recommend.png" /></label>
                    <div class="input_box">
                        <input class="text_box text_border" type="text" name="code" id="code"  value="{$member_card}"
                               style=";" placeholder="请输入推荐人会员号" maxlength="11">
                        <input class="text_box text_border" type="text"   placeholder="推荐人:{$member_name}" readonly="readonly" maxlength="11">
                    </div>
                </div>
                <div class="form_item">
                    <!-- <label class="icon-cell_phone" for="code"></label> -->
                    <label><img src="__PUBLIC__/wap/img/lmy.png" /></label>
                    <div class="input_box">
                        <input class="text_box text_border" type="text" name="member_name"   value="" placeholder="请输入昵名" maxlength="11">
                    </div>
                </div>
                <div class="form_item">
                    <!-- <label class="icon-cell_phone" for="mobile"></label> -->
                    <label><img src="__PUBLIC__/wap/img/phon.png" /></label>
                    <div class="input_box">
                        <input class="text_box text_border" type="tel" name="mobile" id="mobile" placeholder="请输入手机号码" maxlength="11">
                    </div>
                </div>
            </div>
            <!--   <div class="error_tips"><span class="icon-warning icon_warning"></span>&nbsp;请输入校验码</div> -->

            <!--  <div class="btn_box">
                <a href="javascript: void(0);" class="btn phone_reg_btn disable">注册</a>
            </div> -->
        </div>




        <div class="step_2">
            <div class="form_box">
                <div class="form_item">
                    <!-- <label class="icon-cell_phone" for="mobile_code"></label> -->
                    <label><img src="__PUBLIC__/wap/img/syzm.png" /></label>
                    <div class="input_box">
                        <input class="text_message text_border" type="text" name="mobile_code" id="mobile_code" placeholder="请输入验证码" maxlength="6">
                        <a href="javascript:;" class="again_message  send_sms">
                            <span class="text get_sms">获取验证码</span>
                            <span class="countdown" style="display:none;">（<em class="num">60</em>S）</span>
                        </a>
                    </div>
                </div>

                <div class="form_item">
                    <!-- <label class="icon-password" for="mem_password"></label> -->
                    <label><img src="__PUBLIC__/wap/img/ls.png" /></label>
                    <div class="input_box">
                        <input class="text_pwd text_border" type="password" name="mem_password" id="mem_password"  placeholder="输入密码(6-20位字母，数字或符号组合)" maxlength="20">
                    </div>
                </div>
                <div class="form_item">
                    <!-- <label class="icon-password" for="rep_password"></label> -->
                    <label><img src="__PUBLIC__/wap/img/ls.png" /></label>
                    <div class="input_box">
                        <input class="text_pwd text_border" type="password" name="rep_password" id="rep_password"  placeholder="重复密码" maxlength="20">
                    </div>
                </div>
            </div>
            <!--<div class="error_tips">
                <span class="icon-warning icon_warning"></span>
                验证码错误
            </div>-->


            <!--address  start-->
            <div class="form_box">
                <div class="form-item ">
                    <div   style="     max-width: 290px;line-height: 16px;margin: 0px auto;   color: #ff3c3c;"><span class="icon-warning icon_warning"></span>&nbsp;地区信息设置后不能更改</div>
                </div>
                <div class="form_item">
                    <!-- <label class="icon-cell_phone" for="mobile_code"></label> -->
                    <label>省份</label>
                    <div class="ui-select ui-border-bi disabled">
                            <select id="provinceid" name="provinceid" class="city_p" {$disable}
                                    onchange="choice_province('city')" emptymsg="请选择省" datatype="*">
                                <option value="0">请选择</option>
                                <volist name="citylist['province']" id="vo">
                                    <option value="{$vo.cityid}"
                                    <if condition="$data['provinceid']==$vo['cityid']">selected</if>
                                    >{$vo.cityname}</option>
                                </volist>
                            </select>
                    </div>
                </div>

                <div class="form_item">
                    <!-- <label class="icon-password" for="mem_password"></label> -->
                    <label>城市</label>
                    <div class="ui-select ui-border-bi disabled">

                            <select id="cityid" name="cityid" class="city_c" {$disable} onchange="choice_city('city')"
                                    emptymsg="请选择市" datatype="*">
                                <option value="0">请选择</option>
                                <volist name="citylist['city']" id="vo">
                                    <option value="{$vo.cityid}"
                                    <if condition="$data['cityid']==$vo['cityid']">selected</if>
                                    >{$vo.cityname}</option>
                                </volist>
                            </select>

                    </div>
                </div>
                <div class="form_item">
                    <label>区县</label>
                    <div class="ui-select ui-border-bi disabled">
                        <if condition="(!empty($city))">
                            <input type="hidden" id="areaid" name="areaid" value="{$data.areaid}" />{$city.area.area}
                            <else/>
                            <select id="areaid" name="areaid" class="city_a" {$disable} emptymsg="请选择区" datatype="*">
                                <option value="0">请选择</option>
                                <volist name="citylist['area']" id="vo">
                                    <option value="{$vo.cityid}"
                                    <if condition="$data['areaid']==$vo['cityid']">selected</if>
                                    >{$vo.cityname}</option>
                                </volist>
                            </select>
                        </if>
                    </div>
                </div>
            </div>
            <!--address  end-->



            <div class="agreement">
                <label><input type="checkbox" name="fuwu" id="fuwu" value="1" checked>点击注册，表示您同意FG峰购</label>
                <a href="{:U('wap/Login/fuwu')}" class="license-terms">《用户协议》</a>
            </div>
            <div class="btn_box" >
                <a href="javascript: void(0);" class="btn phone_reg_btn">注册</a>
            </div>
        </div>
    </div>
</form>


<script type="text/javascript" src="__PUBLIC__/wap/js/jquery.min.js"></script>

<!--<script src="__PUBLIC__/bootstrap/vendor/jquery-validation/jquery.validate.min.js"></script>-->
<script src="__PUBLIC__/bootstrap/vendor/jquery-validation/jquery.validate.wap.js"></script>
<script src="__PUBLIC__/js/jquery.form.js"></script>
<script type="text/javascript" src="__PUBLIC__/layer/layer.js"></script>
<!--start 红包弹窗-->
<include file="Public/hongbao" />
<!--end 红包弹窗-->
<script>
    jQuery(document).ready(function() {

        /*$('#captcha').click(function(){
            //重载验证码
            var time = new Date().getTime();
            var src='{:U('Wap/Login/verify')}?'+time;
            $(this).attr('src',src);
        });*/
        //FormValidator.init();
        var code_msg="";
        jQuery.validator.addMethod("checkcodetrue", function(value) {
            var mobileval=$("#mobile").val();
            var ret=true;
            var re = /^[0-9]+.?[0-9]*$/;   //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/
            if(value){
                if(!re.test(value)){
                    code_msg="请输入正确的手机号/推荐码";
                    ret=false;
                }
            }
            return ret;
        });
        jQuery.validator.addMethod("checkcode", function(value) {
            var mobileval=$("#mobile").val();
            var ret=true;
            var re = /^[0-9]+.?[0-9]*$/;   //判断字符串是否为数字     //判断正整数 /^[1-9]+[0-9]*]*$/
            if(value){
                if(!re.test(value)){

                }else{
                    if(value==mobileval){
                        ret=false;
                        code_msg="推荐人手机号不能和注册手机号一致";
                    }
                }
            }
            return ret;
        });


        $("#form2").validate({
            rules: {
                code:{
                    checkcodetrue:true,
                    checkcode:true,
                    remote: {
                        url: "{:U('Wap/Login/chk_member_code')}",
                        type: "get",
                        dataType: "json",
                        data: {
                            code: function () {
                                return $("#code").val();　　　　//这个是取要验证的数据
                            }
                        },
                        dataFilter: function (msg) {　　　　//判断控制器返回的内容
                            if (msg== '1') {
                                return true;
                            }else {
                                return false;
                            }
                        }
                    }
                },
                mobile: {
                    required:true,
                    number:true,
                    minlength:11,
                    remote: {
                        url: "{:U('Wap/Login/cheack_mobile')}",
                        type: "get",
                        dataType: "json",
                        data: {
                            mobile: function () {
                                return $("#mobile").val();　　　　//这个是取要验证的数据
                            }
                        },
                        dataFilter: function (msg) {　　　　//判断控制器返回的内容
                            if (msg == "0") {
                                return true;
                            }else {
                                return false;
                            }
                        }
                    }
                },
                /*verify_code: {
                    required:true,
                    remote: {
                        url: "{:U('Wap/Login/checkVerify')}",
                        type: "get",
                        dataType: "json",
                        data: {
                            verify_code: function () {
                                return $("#verify_code").val();　　　　//这个是取要验证的数据
                            }
                        },
                        dataFilter: function (msg) {　　　　//判断控制器返回的内容
                            if (msg == "1") {
                                return true;
                            }else {
                                return false;
                            }
                        }
                    }
                },*/
                mobile_code: {
                    required:true,
                    remote: {
                        url: "{:U('Wap/Login/check_send_reg')}",
                        type: "get",
                        dataType: "json",
                        data: {
                            mobile: function () {
                                return $("#mobile").val();　　　　//这个是取要验证的数据
                            },
                            mobile_code: function () {
                                return $("#mobile_code").val();　　　　//这个是取要验证的数据
                            }
                        },
                        dataFilter: function (msg) {　　　　//判断控制器返回的内容
                            if (msg == "1") {
                                return true;
                            }else {
                                return false;
                            }
                        }
                    }
                },
                mem_password: {
                    required: true,
                    rangelength: [6, 20]
                },
                rep_password: {
                    required: true,
                    rangelength: [6, 20],
                    equalTo: "#mem_password"
                },
                fuwu:'required'
            },
            messages: {
                code:{
                    checkcodetrue:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号/推荐码',
                    checkcode:'<span class="icon-warning icon_warning"></span>&nbsp;推荐人手机号不能和注册手机号一致',
                    remote:'<span class="icon-warning icon_warning"></span>&nbsp;没有找到该推荐人'
                },
                mobile:{
                    required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入手机号码',
                    number:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号码',
                    minlength:'<span class="icon-warning icon_warning"></span>&nbsp;请输入正确的手机号码',
                    remote:'<span class="icon-warning icon_warning"></span>&nbsp;手机号码已注册'
                },
                mobile_code: {
                    required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入手机验证码',
                    remote:'<span class="icon-warning icon_warning"></span>&nbsp;手机验证码不正确'
                },
                mem_password: {
                    required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入密码',
                    rangelength:'<span class="icon-warning icon_warning"></span>&nbsp;密码请保持6-20位'
                },
                rep_password: {
                    required:'<span class="icon-warning icon_warning"></span>&nbsp;请输入重复密码',
                    rangelength:'<span class="icon-warning icon_warning"></span>&nbsp;重复密码请保持6-20位',
                    equalTo:'<span class="icon-warning icon_warning"></span>&nbsp;两次密码输入不一致'
                },
                fuwu:'<span class="icon-warning icon_warning"></span>&nbsp;不同意服务协议不能注册'
            },
            focusInvalid:false,
            success: function(label) {
                // set  as text for IE 
                // alert('ok'); 
                //label.html(" ").addClass("checked"); 
            },
            /*执行ajaxsubmit  */
            submitHandler: function(editform) {

                var options = {
                    url :  "<?php echo U('Wap/Login/doregister'); ?>",
                    type : "post" ,
                    dataType:'json',
                    target : "#loader",
                    error: function(){layer.msg("服务器没有返回数据，可能服务器忙，请重试",{icon:5});},
                    onwait : "正在处理信息，请稍候...",
                    success: function(response){
                        // console.log(response);
                        //$("#loader").fadeIn(500).html(response.data).fadeOut(500); 
                        //$('#editform').hide(2000); 
                        if(response.status==1){
                            //alert("注册成功");
                            layer.msg('注册成功', {icon: 6},function(){
                                //关闭后的操作
                                window.location.href="<?php echo U('Wap/Login/index'); ?>";
                            });
                        }else{
                            layer.msg(response.error, {icon: 5});
                            // alert(response.error);
                        }
                    }
                };
                setTimeout((function(opt){
                    return function(){
                        $('#form2').ajaxSubmit(opt);
                    }
                })(options), 300);
                return false;
            }

        });


        $("#dropdown").change(function(){
            var val=$(this).val();
            if(val>0){
                $(".menu_icons").hide();
            }else{
                $(".menu_icons").show();
            }
        });
        $('.phone_reg_btn').click(function(){
            $('#form2').submit();
        });

        $('.send_sms').click(function(){
            var is_send=$(this).hasClass('disable');
            if(is_send){
                return false;
            }else{
                //短信发送
                $.ajax({
                    url: "{:U('Wap/Login/send_sms')}",
                    type: "get",
                    dataType: "json",
                    data: {
                        mobile: function () {
                            return $("#mobile").val();　　　　//这个是取要验证的数据
                        }/*,
                        verify_code: function () {
                            return $("#verify_code").val();　　　　//这个是取要验证的数据
                        }*/
                    },
                    success: function (msg) {　　　　//判断控制器返回的内容
                        if (msg.status == "1") {
                            //disable
                            // $('#mobile_code').val(msg.code);
                            // alert("验证码发送成功");
                            layer.msg('验证码发送成功', {icon: 6});
                            run_time_out();
                        }else {
                            // alert(msg.msg);
                            layer.msg(msg.msg, {icon: 5});
                        }
                    }
                });
            }
        });

    });
    function run_time_out(){
        var num=$('.num').html();
        num=parseInt(num);
        var is_send=$('.send_sms').hasClass('disable');
        if(num>0){
            $('.get_sms').hide();
            $('.countdown').show();
            $('.send_sms').css('cssText','background-color: #eee;color: #666;-webkit-appearance: none;');
            num--;
            $('.num').html(num);//显示倒计时
            if(!is_send){
                $('.send_sms').addClass('disable');///禁止点击
            }
        }else{
            $('.countdown').hide();
            $('.get_sms').show();
            $('.num').html(60);//初始化倒计时
            $('.send_sms').removeClass('disable');///可以点击
            $('.send_sms').removeAttr('style');
            return false;
        }
        setTimeout('run_time_out()',1000);
    }
</script>



<!--address end-->

<script>
    var get_city_url="{:U('wap/index/get_city')}";
</script>
<script src="__PUBLIC__/js/common.js"></script>
<script>
    jQuery(document).ready(function () {
        //FormValidator.init();

        jQuery.validator.addMethod("byteRangeLength", function (value) {
            var areaid = $("#areaid").val();
            var cityid = $("#cityid").val();
            var provinceid = $("#provinceid").val();
            var ret = false;
            if (areaid > 0 && cityid > 0 && provinceid > 0) {
                ret = true;
            }
            return ret;
        });

        $("#form2").validate({
            rules: {
                /*member_name: 'required',*/
                areaid: 'byteRangeLength',
                /*addr: 'required'*/
            },
            messages: {
                /*member_name: '<span class="icon-warning icon_warning"></span>&nbsp;请输入昵称',*/
                areaid: '<span class="icon-warning icon_warning"></span>&nbsp;请选择完整的省市区',
            },
            focusInvalid: false,
            success: function (label) {
                // set  as text for IE 
                // alert('ok'); 
                //label.html(" ").addClass("checked"); 
            },
            /*执行ajaxsubmit  */

                setTimeout((function (opt) {
                    return function () {
                        $('#form2').ajaxSubmit(opt);
                    }
                })(options), 300);
                return false;
            }

        });
    });
</script>
<!--address end-->
</body>
</html>